"""
协议模块包初始化文件：对外动态提供所有实现的协议接口类，协议工厂根据暴露类进行自动加载构建协议实例
协议工厂根据协议类型字符串，自动加载对应的协议实现类，构建协议实例
"""

# 现场总线协议 (Fieldbus Protocols)
# from ..protocols.fieldbus.bacnet.bacnet_interface import BacnetInterface
# from ..protocols.fieldbus.canopen.canopen_interface import CanopenInterface
# from ..protocols.fieldbus.devicenet.devicenet_interface import DeviceNetInterface
# from ..protocols.fieldbus.ethercat.ethercat_interface import EthercatInterface
# from ..protocols.fieldbus.modbus.modbus_rtu import ModbusRtuInterface
# from ..protocols.fieldbus.modbus.modbus_tcp import ModbusTcpInterface
# from ..protocols.fieldbus.profinet.profinet_interface import ProfinetInterface
# from ..protocols.fieldbus.s7.s7_interface import S7Interface

# 工业以太网协议 (Industrial Ethernet Protocols)
# from ..protocols.industrial_networks.ethernet_ip.ethernetip_interface import EthernetIpInterface
from ..protocols.industrial_networks.opcua.opcua_interface import OpcUaInterface

# 标准通信协议 (Standard Communication Protocols)
# from ..protocols.standard.http.http_interface import HttpInterface
# from ..protocols.standard.serial.serial_interface import SerialInterface
from ..protocols.standard.socket.socket_interface import SocketInterface
# from ..protocols.standard.websocket.websocket_interface import WebSocketInterface

# 定义__all__列表，明确暴露的接口
__all__ = [
    # 现场总线协议
    # 'BacnetInterface',
    # 'CanopenInterface',
    # 'DeviceNetInterface',
    # 'EthercatInterface',
    # 'ModbusRtuInterface',
    # 'ModbusTcpInterface',
    # 'ProfinetInterface',
    # 'S7Interface',

    # 工业以太网协议
    # 'EthernetIpInterface',
    'OpcUaInterface',

    # 标准通信协议
    # 'HttpInterface',
    # 'SerialInterface',
    'SocketInterface',
    # 'WebSocketInterface'
]

# 协议类型到类的映射配置，供ProtocolFactory使用
PROTOCOL_CLASS_MAP = {
    # 现场总线协议
    # "bacnet": BacnetInterface,
    # "canopen": CanopenInterface,
    # "devicenet": DeviceNetInterface,
    # "ethercat": EthercatInterface,
    # "modbus_rtu": ModbusRtuInterface,
    # "modbus_tcp": ModbusTcpInterface,
    # "profinet": ProfinetInterface,
    # "s7": S7Interface,

    # 工业以太网协议
    # "ethernet_ip": EthernetIpInterface,
    "opcua": OpcUaInterface,

    # 标准通信协议
    # "http": HttpInterface,
    # "https": HttpInterface,  # HTTPS使用相同的接口类
    # "serial": SerialInterface,
    "socket": SocketInterface,
    # "websocket": WebSocketInterface
}

# 协议工厂配置说明：
# ProtocolFactory.create_protocol(protocol_type, config) 方法根据以下逻辑创建实例：
# 1. 首先检查config中是否包含"communication_class"配置项，如果存在则使用该配置指定的类创建实例
# 2. 如果没有"communication_class"配置项，则根据protocol_type参数查找PROTOCOL_CLASS_MAP映射
# 3. 如果找到对应的类，则使用该类创建实例并返回
# 4. 如果未找到对应的类，则抛出ValueError异常